﻿using System;
using System.ServiceModel;
using System.Windows;
namespace SXDSVC3
{


    public partial class MainWindow : Window
    {
        public static log4net.ILog log = log4net.LogManager.GetLogger(
   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        ServiceHost host;
        public MainWindow()
        {
            try
            {
                log.Info("Start  InitializeComponent");
                InitializeComponent();
                log.Info("End InitializeComponent");
                this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
                this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
            }
            catch(Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }

        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            if (host != null)
                host.Close();
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (host != null)
                    return;
                /*var svc = new LEDSVCWIN();

                svc.Open();*/
                host = new ServiceHost(typeof(LEDSVCWIN));
                log.Info("Host is New");
                host.Open();
                log.Info(host.ToString());
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
    }
}
